package com.baizhi.service.impl;

import com.baizhi.dao.UserDao;
import com.baizhi.entity.User;
import com.baizhi.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
class UserServiceImpl implements UserService {
    @Autowired
    private UserDao userDao;

    public void insert(User user) {
        userDao.insert(user);
    }

    public void update(User user) {
        userDao.update(user);
    }

    public void delete(int[] ids) {
        userDao.delete(ids);
    }

    public Map selectUserByPage(int page, int rows) {
        Map map=new HashMap();

        int total=userDao.selectTotal();
        map.put("total",total);

        int start=(page-1)*rows;
        int pageSize=rows;
        List<User> list=userDao.selectUserByPage(start,pageSize);
        map.put("rows",list);
        return map;
    }

    @Override
    public List<User> selectAll() {
        return userDao.selectAll();
    }
}
